package Config

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
)

type ConfigStruct struct {
	WaetherPort       string
	WaetherDBIP       string
	WaetherDBUser     string
	WaetherDBPassword string
	WaetherDBDBName   string
	WaetherApiKey     string
}

func (config *ConfigStruct) Load(path string) error {
	bytes, err := ioutil.ReadFile(path)
	if err != nil {
		fmt.Println("ReadFile: ", err.Error())
		return err
	}

	if err := json.Unmarshal(bytes, &config); err != nil {
		fmt.Println("Unmarshal: ", err.Error())
		return err
	}

	return nil
}
